package com.dayuanit.dy17.mix.map;

import java.util.LinkedHashMap;
import java.util.Map;

public class TestLRU {
    public static void main(String[] args) {
        //LRU缓存淘汰
        LinkedHashMap<String, String> lru = new LinkedHashMap(16, 0.75f, true);
        lru.put("a", "alibaba");
        lru.put("b", "baidu");
        lru.put("c", "coco");
        lru.put("d", "dayuanit");

        for (Map.Entry<String,String> entry : lru.entrySet()) {
            System.out.println(entry.getKey() + "-" + entry.getValue());
        }

        System.out.println("-------------------");

        lru.get("a");
        lru.get("a");
        lru.get("b");


        for (Map.Entry<String,String> entry : lru.entrySet()) {
            System.out.println(entry.getKey() + "-" + entry.getValue());
        }

    }
}
